﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using OrderManagement;

namespace OrderWinForm
{
    public partial class OrderCreate : Form
    {
        public OrderCreate(Form1 form)
        {
            InitializeComponent();
            C_name.DataBindings.Add("Text", this.customer, "Name");
            address.DataBindings.Add("Text", this.customer, "Address");
            phone.DataBindings.Add("Text", this.customer, "Phone");
            //ID.DataBindings.Add("Text", this, "OrderID");
            this.form1 = form;
        }
        private Form1 form1;

        private Customers customer=new Customers();
        private String OrderID="";
        private List<Goods> goods=new List<Goods>();
        private void AddGood_button_Click(object sender, EventArgs e)
        {
            goods.Add(new Goods(Gname.Text, Convert.ToDouble(Price.Text),Convert.ToInt32(Period.Text),Convert.ToInt32(Num.Text)));
            Gname.Clear();
            Price.Clear();
            Period.Clear();
            Num.Clear();
        }

        private void Addover_button_Click(object sender, EventArgs e)
        {
            goods.Add(new Goods(Gname.Text, Convert.ToDouble(Price.Text), Convert.ToInt32(Period.Text), Convert.ToInt32(Num.Text)));
            OrderDetails details = new OrderDetails(this.goods);
            Order neworder = new Order(this.customer, details, ID.Text);
            //form1.service.AddOrder(neworder);   
            form1.Order_bindingSource.Add(neworder);
            this.Hide();

        }
    }
}
